<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String newsid=request.getParameter("id"); 
String fr=request.getParameter("fr"); 

%>
<script type="text/javascript">
<!--

//-->
</script>
<style>
<!--
 	.btn_newsadd{
 		margin-left:50px; 
 	}
-->
</style>
<link href="css/style.css" rel="stylesheet" type="text/css" /> 
<link href="<%=path %>/resources/date/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="<%=path %>/css/bootstrap.min.css" />
<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=path %>/resources/date/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="<%=path %>/resources/date/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="<%=path %>/js/resources/common.js"></script>
<%-- ueditor js --%> 
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="<%=path %>/resources/ueditor/lang/zh-cn/zh-cn.js"></script>


    <jsp:include page="common.jsp"></jsp:include>
    
    
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li>系统设置</li>
    <li><span id="lujing">人才招聘</span></li> 
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>基本信息</span></div>
    
    <ul class="forminfo">
    <li><label>岗位名称</label>
    	<input name="name" id="name" type="text" class="dfinput" style="width:60%;"/><i>*岗位名称不能超过50个字符</i>
    </li>
    <li><label>月薪</label>
    	<input name="money" id="money" type="text" class="dfinput" style="width:60%;"/><i>*</i>
    </li>
    <li><label>其他福利</label>
    	<input name="ext" id="ext" type="text" class="dfinput" style="width:60%;"/><i></i>
    </li>
    <li><label>工作地点</label>
    	<input name="address" id="address" type="text" class="dfinput" style="width:60%;"/>
    </li>
    	
    <li><label>出差</label>
    	<input name="businessTrip" id="businessTrip" type="text" class="dfinput" style="width:60%;"/>
		
	</li>
    <li><label>招聘状态</label>
    	<select id="adStatus" name="adStatus" class="form-control" style="width:345px;">
			<option value='招聘中' class="form-control" selected="selected">招聘中</option>
			<option value='招聘完毕' class="form-control" >招聘完毕</option>
		</select>
    </li>
    <li><label>招聘人数</label>
    	<input name="adCount" id="adCount" type="text" class="dfinput" style="width:60%;"/>
    </li>
    <li><label>发布日期</label>
    	<input name="adDate" id="adDate" type="text" class="dfinput form_datetime" /><i>最晚时间为当前时间</i>
    </li>
    <li><label>截止日期</label>
    	<input name="enDate" id="enDate" type="text" class="dfinput form_datetime" /><i>最早时间为当前时间</i>
    </li>
    <li><label>要求</label><br><br><br>
    	<textarea name="askKills" id="askKills" type="text" class="" style="width:90%;height:300px;"></textarea>
    </li>
    <li><label>工作内容</label><br><br><br>
    	<textarea name="work" id="work"  type="text" class="" style="width:90%;height:300px;"></textarea>
    </li>
    
    <li><label>&nbsp;</label>
    	<input name="" id="news_save" type="button" class="btn btn-primary btn_newsadd" value="确认保存"/>
    	<input name="" id="news_reset" type="button" class="btn btn-primary btn_newsadd" value="重置"/>
    </li>
    </ul>
    
    
    
    </div>
    
 <script type="text/javascript" >
 
	 var path='<%=path%>';
	 var ue1 = UE.getEditor('askKills',{
		 imageUrlPrefix:path+'/'
	 });
	 var ue2 = UE.getEditor('work',{
		 imageUrlPrefix:path+'/'
	 });
	 var pid='<%=newsid%>';
	 var fr='<%=fr%>';
 
 $(function(){
	
 });
 
 $("#adDate").datetimepicker({
		language: 'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose:true,
		startView: 2,  
        minView: 2, 
		endDate:new Date()
 });
 $("#enDate").datetimepicker({
		language: 'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose:true,
		startView: 2,  
        minView: 2, 
		startDate:new Date()
 });
 
 $("#news_save").unbind("click").bind("click",function(){
	 
	 if(validField()){
		 $.post(path+"advertiseAction_save.action",{
			 money:$("#money").val(),
			 ext:$("#ext").val(),
			 address:$("#address").val(),
			 businessTrip:$("#businessTrip").val(),
			 adStatus:$("#adStatus").val(),
			 adDate:$("#adDate").val(),
			 enDate:$("#enDate").val(),
			 adCount:$("#adCount").val(),
			 name:$("#name").val(),
			 askKills:ue1.getContent(),
			 work:ue2.getContent()
		 },function(res){
			 res=eval('('+res+')');
			 alert(res.msg);
			 window.location.href="advertiselist.jsp";
		 });
	 }
 }); 
 
 function validField(){
	 var money=$("#money").val();
	 var ext=$("#ext").val();
	 var address=$("#address").val();
	 var businessTrip=$("#businessTrip").val();
	 var adStatus=$("#adStatus").val();
	 var adDate=$("#adDate").val();
	 var enDate=$("#enDate").val();
	 var adCount=$("#adCount").val();
	 var name=$("#name").val();
	 var askKills=ue1.getContent();
	 var work=ue2.getContent();
	 
	 
	 if(!money){
		 alert("月薪不能为空");
		 return false;
	 }
	 if(!name){
		 alert("岗位名称不能为空");
	 	return false;
	 }
	 var r = /^\+?[1-9][0-9]*$/; 
	 
	 if(!r.test(adCount)){
		 alert("招聘人数必须是正整数");
		 return false;
	 }
	 return true;	 
 }
 
 $("#news_reset").click(function(){ 
		/*jquery 没有reset 方法，使用dom 的，reset 不能重置 textarea，手动重置 textarea */
		$("input[type=text]").val('');
		ue1.setContent('');
		ue2.setContent('');
	});
 
 </script>